-
Notifications
You must be signed in to change notification settings - Fork 6.7k
fix(typeahead): run validators manually on select #3352
Conversation
@@ -251,6 +251,11 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap | |||
$setModelValue(originalScope, model); | |||
modelCtrl.$setValidity('editable', true); | |||
|
|||
if (modelCtrl.$$lastCommittedViewValue === modelCtrl.$viewValue) { | |||
// angular will check if model value changed to run validators, so we need to run it manually | |||
modelCtrl.$$runValidators(undefined, modelCtrl.$modelValue, modelCtrl.$viewValue, angular.noop); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are undocumented API. Is there any way to this with the documented API (prefixed with a single $
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think it's enough to run $setValidity
for parse
key
var match = $(findMatches(element)[0]).find('a')[0]; | ||
$(match).click(); | ||
|
||
expect($scope.form.input.$error.parse).toBeUndefined(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add a check for the $error before the click as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parsed
error was introduced in 1.3, so it's impossible to test it in current environment ( angular 1.2.16 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sagens42 we've updated the project to AngularJS 1.3 recently
Fixed in #3166 Closing |
It looks like this is still an issue with the new |
@katerberg - yes, please. Here are the instructions for doing so, thanks. |
fix for #3311